import { Loading, MessageBox } from 'element-ui'
let loadingInstance
const menu0 = [
  { type: 1, index: 'appAdd', class: 'el-icon-setting', title: '小程序信息' }
]
const menu1 = [
  {
    type: 0,
    index: '1',
    class: 'el-icon-star-on',
    title: '公众号信息',
    submenu: [
      { index: 'appList', title: '公众号信息列表' },
      { index: 'appModify', title: '公众号信息修改' }
    ]
  },
  { type: 1, index: 'index', class: 'el-icon-picture', title: 'banner图片' },
  // { type: 1, index: 'Order', class: 'el-icon-news', title: '订单管理' },
  {
    type: 0,
    index: '5',
    class: 'el-icon-menu',
    title: '科室管理',
    submenu: [
      { index: 'proTypeList', title: '科室列表' },
      { index: 'proTypeAdd', title: '科室新增' }
    ]
  },
  {
    type: 0,
    index: '9',
    class: 'el-icon-view',
    title: '挂号级别',
    submenu: [
      { index: 'numberList', title: '级别列表' },
      { index: 'numberAdd', title: '新增级别' }
    ]
  },
  {
    type: 0,
    index: '7',
    class: 'el-icon-tickets',
    title: '医生管理',
    submenu: [
      { index: 'proDataList', title: '医生列表' },
      { index: 'proDataAdd', title: '医生新增' }
    ]
  },
  {
    type: 0,
    index: '11',
    class: 'el-icon-bell',
    title: '医生排班',
    submenu: [
      { index: 'dutyList', title: '排班列表' },
      { index: 'dutyAdd', title: '排班新增' }
    ]
  },
  { type: 1, index: 'Order', class: 'el-icon-location', title: '预约列表' },
  { type: 1, index: 'Contact', class: 'el-icon-news', title: '医院介绍' },
  {
    type: 0,
    index: '13',
    class: 'el-icon-setting',
    title: '用户管理',
    submenu: [
      { index: 'userList', title: '用户列表' },
      { index: 'userAdd', title: '用户新增' }
    ]
  }
  // { type: 1, index: 'Modify', class: 'el-icon-edit-outline', title: '修改密码' }
  // { type: 1, index: 'About', class: 'el-icon-view', title: '关于我们' }
]
const menu2 = [
  { type: 1, index: 'Order', class: 'el-icon-location', title: '预约列表' }
]
export default {
  menu0,
  menu1,
  menu2,
  testlog: function () {
    console.log('123')
  },
  open: function () {
    loadingInstance = Loading.service({
      lock: true,
      text: 'Loading',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    })
  },
  close: function () {
    loadingInstance.close()
  },
  messageTwo (message, title) {
    MessageBox.alert(message, title, {
      confirmButtonText: '确定'
    })
  },
  catchbox (that) {
    that.$pub.close()
    that.$router.push({ name: 'login' })
    // MessageBox.alert('登录超时，请退出重新登录', '提示信息', {
    //   confirmButtonText: '确定',
    //   callback: action => {
    //   }
    // })
  },
  failcode (that, code, message) {
    if (code === 401) {
      MessageBox.alert('登录超时，请退出重新登录', '提示信息', {
        confirmButtonText: '确定',
        callback: action => {
          that.$router.push({ name: 'login' })
        }
      })
    }
    if (code === -1) {
      MessageBox.alert(message, '提示信息', {
        confirmButtonText: '确定'
      })
    }
  }
}
